package com.qqpz.sign_project.service.impl;

import com.qqpz.sign_project.entity.Goods;
import com.qqpz.sign_project.mappers.GoodsMapper;
import com.qqpz.sign_project.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    private GoodsMapper goodsMapper;
    @Override
    public List<Goods> queryAllGoods() {
        return goodsMapper.queryAllGoods();
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateGoodsById(Goods goods) {
        return goodsMapper.updateGoodsById(goods);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int createGoods(Goods goods) {
        int i;
        try{
            goodsMapper.createGoods(goods);
            i=1;
        }catch (Exception e){
            i=0;
        }
        return i;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteGoodsById(String id) {
        return goodsMapper.deleteGoodsById(id);
    }
}
